package com.jeesite.modules.rt.web;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.rt.entity.RtDeviceBohao;
import com.jeesite.modules.rt.service.RtDeviceBohaoService;

/**
 * rt_device_bohaoController
 * @author 李寒冰
 * @version 2024-09-26
 */
@Controller
@RequestMapping(value = "${adminPath}/rt/rtDeviceBohao")
public class RtDeviceBohaoController extends BaseController {

	@Autowired
	private RtDeviceBohaoService rtDeviceBohaoService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public RtDeviceBohao get(String id, boolean isNewRecord) {
		return rtDeviceBohaoService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("rt:rtDevice:view")
	@RequestMapping(value = {"list", ""})
	public String list(RtDeviceBohao rtDeviceBohao, Model model) {
		model.addAttribute("rtDeviceBohao", rtDeviceBohao);
		return "modules/rt/rtDeviceBohaoList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("rt:rtDevice:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<RtDeviceBohao> listData(RtDeviceBohao rtDeviceBohao, HttpServletRequest request, HttpServletResponse response) {
		rtDeviceBohao.setPage(new Page<>(request, response));
		Page<RtDeviceBohao> page = rtDeviceBohaoService.findPage(rtDeviceBohao);
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("rt:rtDevice:view")
	@RequestMapping(value = "form")
	public String form(RtDeviceBohao rtDeviceBohao, Model model) {
		model.addAttribute("rtDeviceBohao", rtDeviceBohao);
		return "modules/rt/rtDeviceBohaoForm";
	}

	/**
	 * 保存数据
	 */
	@RequiresPermissions("rt:rtDevice:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated RtDeviceBohao rtDeviceBohao) {
		rtDeviceBohaoService.save(rtDeviceBohao);
		return renderResult(Global.TRUE, text("保存rt_device_bohao成功！"));
	}
	
	/**
	 * 删除数据
	 */
	@RequiresPermissions("rt:rtDevice:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(RtDeviceBohao rtDeviceBohao) {
		rtDeviceBohaoService.delete(rtDeviceBohao);
		return renderResult(Global.TRUE, text("删除rt_device_bohao成功！"));
	}
	
}